#!/bin/sh

. $HOME/bin/config.sh

BUILD_PATH=$HOME

function Check {
	if [ ! -d "$BUILD_PATH/src" ] ; then
		mkdir $BUILD_PATH/src
	fi
	rm -rf $BUILD_PATH/src/$appname
	mkdir $BUILD_PATH/src/$appname
	cd $BUILD_PATH/src/;
	echo -e "\nInit $appname ... \n";
	git clone $url;
	cd $BUILD_PATH/src/$appname;
	echo -e "\n-------------------------------------------------------------------------\n\nCheck Branch Name ... \n"
	git branch -r | grep $branchname
	if [ $? = 0 ] ;	then
		git branch -a;
		echo -e "\nGit Checkout $branch ... \n"
		git checkout $branchname;
		echo -e "\nNow you are `git status` !!! \n"
	else
		echo -e "!!!Branch $branchname is not exist . Please check the branch name !!!\n\n-------------------------------------------------------------------------\n"
		return 1
	fi
}

#===================
#Function main()
#===================
function Main {
	Check
	if [ $? -eq 1 ] ; then
		exit 1
	fi
}

Main
